#include "PolylineEntity.h"
#include <QPainter>

PolylineEntity::PolylineEntity(void)
{
}


PolylineEntity::~PolylineEntity(void)
{
}

void PolylineEntity::render( RenderContext* renderContext )
{
	renderContext->painter()->save();

	QPen pen(QBrush(getColor()), getWidth());
	renderContext->painter()->setPen(pen);
	QPolygon polygon = renderContext->mapToPixel().mapToScreen(_polyline);
	renderContext->painter()->drawPolyline(polygon);

	renderContext->painter()->restore();
}

void PolylineEntity::traslate( const Point& point )
{
	for (size_t i = 0; i < _polyline.getPointCount(); ++i)
	{
		Point& pt = _polyline[i];

		pt.setX(pt.getX() + point.getX());
		pt.setY(pt.getY() + point.getY());
	}
}

TGS::GeoMath::Envelope PolylineEntity::getEnvelope() const
{
	if(!isSpaceModel()) return Envelope();

	return _polyline.getEnvelope();
}
